package com.yanqu.road.server.cmd.activity;

import com.yanqu.road.pb.activity.ShareProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.activity.share.ShareMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

import java.math.BigInteger;

@Cmd(code = GameProtocol.S_SHARE_SYNC_DATA,desc = "")
public class SyncShareDataCmd implements Command {
    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        ShareProto.SyncUserDataToInviterMsg msg = ShareProto.SyncUserDataToInviterMsg.parseFrom(packet.getBytes());
        long userId = msg.getInviterUserId();
        ShareProto.InvitationDataMsg data = msg.getData();
        ShareMgr.changeShareData(userId, data.getServerId(), data.getUserId(), new BigInteger(data.getEarnSpeed()), data.getVipExp(), data.getRegisterTime(), data.getOpenId());
    }
}
